/**
 * 
 */
package entity;


import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;


/**
 * @author Chigco.Orc
 *
 */
@Entity
public class User {
	
	/*
	 * 必填资料
	 */
	
	private Long id;
	private String userId;
	private String pass;
	private String eMail;
	private int state;  //用户状态 0正常 1 禁止登录
	private int type;	//用户类型 0未认证 1已认证
	private int integral;  //用户积分
	private Long registTime;	//注册时间
	private Long lastLoginTime; //最后登录时间
	private List<Product> products;
	private List<UserInfo> userInfos;
	private List<Order> orders;
	
	
	
	
	
	

	@Id
	@GeneratedValue
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	/*
	 * 用户与用户信息的关系：加了唯一约束的一对多
	 */
	@OneToMany(mappedBy="user")
	public List<UserInfo> getUserInfos() {
		return userInfos;
	}
	/*
	 * 用户与商品的关系：一对多
	 */
	@OneToMany(mappedBy="user")
	public List<Product> getProducts() {
		return products;
	}
	public void setProducts(List<Product> products) {
		this.products = products;
	}
	/*
	 * 用户与订单的关系：一对多
	 */
	@OneToMany(mappedBy="user")
	public List<Order> getOrders() {
		return orders;
	}
	public void setOrders(List<Order> orders) {
		this.orders = orders;
	}
	
	public void setUserInfos(List<UserInfo> userInfos) {
		this.userInfos = userInfos;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getPass() {
		return pass;
	}
	public void setPass(String pass) {
		this.pass = pass;
	}

	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = 0;
	}
	public int getIntegral() {
		return integral;
	}
	public void setIntegral(int integral) {
		this.integral = 0;
	}
	public Long getRegistTime() {
		return registTime;
	}
	public void setRegistTime(Long registTime) {
		this.registTime = registTime;
	}
	public Long getLastLoginTime() {
		return lastLoginTime;
	}
	public void setLastLoginTime(Long lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		if(type<0) this.type = 0;
		else
		this.type = type;
	}
	public String geteMail() {
		return eMail;
	}
	public void seteMail(String eMail) {
		this.eMail = eMail;
	}
	

}
